<template>
  <div class="talent-detail-page">
    <ul class="list">
      <li v-for="(item, index) in listData" :key="index">
        <h2>
          <span class="tit" >{{item.title}}</span>
          <span class="tag status1">{{item.legal_status}}</span>
        </h2>
        <p class="abst" v-html="item.abst"></p>
        <ul class="child-list">
          <li v-for="(child, index2) in item.children" :key="index2">
            <i class="circle"></i>
            <div class="panel">
              <h4>{{child.ad}}</h4>
              <div class="box">
                <h3>
                  <span class="tit" >{{child.title}}</span>
                  <span class="tag status1">{{child.legal_status}}</span>
                </h3>
                <p class="abs">{{(child.abst && child.abst.length > 150 && !child.toggle) ? child.abst.substr(0, 150) + '...' : child.abst}}</p>
                <span v-if="child.abst && child.abst.length > 150" class="toggle" @click="toggleAbs(child)">{{child.toggle ? '收起' : '展开'}}</span>
              </div>
            </div>
          </li>
        </ul>
      </li>
      <li v-if="listData.length<=0">
        {{noData}}
      </li>
    </ul>
    <!-- 分页 -->
    <div class="pagination">
      <el-pagination
        background
        layout="prev, pager, next"
        :total="total"
        :page-size="ips"
        :current-page.sync="ipi"
        @current-change="getCurrentPage"
        class="el-pagination">
      </el-pagination>
    </div>
  </div>
  <!-- <img src="../../../../../assets/img/xueshuwenxian.jpg" alt="" ondragstart="return false"> -->
</template>

<script>
import {shuangjibanData, shimoData} from './academicData'
export default {
  props: {
    curSelectedNode: {
      type: Object
    }
  },
  data() {
    return {
      listData: [],
      // 专利类型
      value1: '',
      options1: [],
      // 公开日
      value2: '',
      options2: [],
      ipi: 1,
      ips: 5,
      total: 0,
      noData: '加载中...'
    }
  },
  methods: {
    init() {
      this.listData = shuangjibanData
    },
    toggleAbs(item) {
      item.toggle = !item.toggle
    },
    getCurrentPage(val) {
      this.ipi = val
    },
  },
  watch: {
    curSelectedNode() {
      if (this.curSelectedNode.label === '石墨材料加工') {
        this.listData = shimoData
      } else {
        this.listData = shuangjibanData
      }
    }
  },
  mounted() {
    this.init()
  }
}
</script>

<style lang="scss" scoped>
.talent-detail-page {
  position: relative;
  text-align: left;
  background-color: #fff;
  .list {
    position: relative;
    padding-left: 0;
    padding-top: 40px;
    margin-left: 20px;
    margin-right: 40px;
    list-style: none;
    h2 {
      margin-bottom: 16px;
      .tit {
        font-size: 20px;
        color: #241c75;
        // cursor: pointer;
      }
      .tag {
        float: right;
        line-height: 28px;
        padding: 0 15px;
        border-radius: 4px;
        font-weight: normal;
        font-size: 14px;
        color: #fff;
        &.status1 {
          background-color: #41b3a2;
        }
        &.status2 {
          background-color: #c44b5c !important;
        }
      }
    }
    .abst {
      line-height: 24px;
      margin-bottom: 24px;
      font-size: 14px;
      color: #7674a3;
    }
    li {
      position: relative;
      padding-left: 36px;
      padding-bottom: 40px;
      &:last-of-type {
        padding-bottom: 0;
      }
      ul {
        li {
          border-left: 1px solid #65c6f5;
        }
      }
      .circle {
        position: absolute;
        top: 0;
        left: -5px;
        display: block;
        width: 10px;
        height: 30px;
        background-color: #fff;
        &:before {
          position: absolute;
          top: 10px;
          left: 0;
          width: 10px;
          height: 10px;
          border-radius: 50%;
          background-color: #65c6f5;
          content: '';
        }
      }
      .panel {
        position: relative;
        h4 {
          line-height: 30px;
          margin-bottom: 20px;
          font-size: 18px;
          color: #241c75;
        }
        .box {
          padding: 20px 30px;
          background-color: #f7f9fc;
          h3 {
            margin-bottom: 16px;
            .tit {
              font-size: 20px;
              color: #241c75;
              // cursor: pointer;
            }
            .tag {
              float: right;
              line-height: 28px;
              padding: 0 15px;
              border-radius: 4px;
              font-weight: normal;
              font-size: 14px;
              color: #fff;
              &.status1 {
                background-color: #41b3a2;
              }
              &.status2 {
                background-color: #c44b5c !important;
              }
            }
          }
          .patent-number {
            margin-bottom: 16px;
            font-size: 14px;
            color: #7674a3;
            .tit {
              display: inline-block;
              width: 65px;
              color: #241c75;
            }
          }
          .abs {
            line-height: 22px;
            margin-bottom: 24px;
            font-size: 14px;
            color: #7674a3;
          }
          .toggle {
            color: #6f6dd8;
            &:hover {
              opacity: .8;
              cursor: pointer;
            }
          }
        }
      }
    }
  }
  .pagination {
    padding: 30px 0;
    text-align: center;
  }
}
</style>